﻿package com.firewolf.iteratorAndComponent.combine.main;

import java.util.Iterator;

import com.firewolf.iteratorAndComponent.combine.MenuComponent;

public class Waitor {
	private MenuComponent allMenus;
	public Waitor(MenuComponent allMenus){
		this.allMenus = allMenus ;
	}
	public void printAllMenus(){
		allMenus.print();
	}
	
	//想找出所有的素菜，需要遍历所有的菜单项
	@SuppressWarnings("rawtypes")
	public void printVegetarianMenu(){
		Iterator iterator = allMenus.getIterator();
		System.out.println("Vegetarian Menu ： ");
		while(iterator.hasNext()){
			MenuComponent menuComponent = (MenuComponent) iterator.next();
			try{
				if(menuComponent.isVegetarian()){
					menuComponent.print();
				}
			}catch(UnsupportedOperationException e){};
		}
	}
}
